﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using ModuleDALCore;
namespace DAL
{
	public class DANHMUCTIENSUBENHDAO:DALBase
	{
		public DANHMUCTIENSUBENHDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPDANHMUCTIENSUBENH"; }
			set { _SpName = value; }
		}
		public DataTable GetListTSB()
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new DANHMUCTIENSUBENH(), null), ConvertClassToArray.GetValues(new DANHMUCTIENSUBENH(), 0));
				return dt;
			}
			catch { return null; }
		}
		public List<DANHMUCTIENSUBENH> GetListTSBs()
		{
			dt = new DataTable();
			List<DANHMUCTIENSUBENH> ds = new List<DANHMUCTIENSUBENH>();
			try
			{
				
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new DANHMUCTIENSUBENH(), null), ConvertClassToArray.GetValues(new DANHMUCTIENSUBENH(), 0));
				ds = (List<DANHMUCTIENSUBENH>)ConvertDatatableToList.ConvertTo<DANHMUCTIENSUBENH>(dt);
			}
			catch { return null; }
			return ds;
		}
		public String CreatenewId()
		{
			try
			{
				return "TSB" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new DANHMUCTIENSUBENH(), null), ConvertClassToArray.GetValues(new DANHMUCTIENSUBENH(), 4));

			}
			catch { return null; }
		}
		public bool INSERT(DANHMUCTIENSUBENH cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 1)) == 1);

			}
			catch { return false; }
		}
		public bool UPDATE(DANHMUCTIENSUBENH cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv,2)) == 1);

			}
			catch { return false; }
		}
		public bool DELETE(DANHMUCTIENSUBENH cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

			}
			catch { return false; }
		}
		
	}
}
